<?php
/**
 ***** 扶摇而上、抱守本真 ******
 * @author Dana
 * @Date 2021/5/28
 */

$increment = 7;
$add = function ($i, $j) use ($increment) {
    return $i + $j + $increment;
};

$files = [
    'ziggy.txt',
    '10steps.doc',
    '11pants.org',
    'frank.mov'
];

usort($files);

usort($files, function ($a, $b) {
    return strnatcmp($b, $a);
});

// 修改 改变数组元素的值
function myFunction(&$value, $key)
{
    $value = "yellow";
}

$a = [
    'a' => 'red',
    'b' => 'green',
    'c' => 'blue'
];

array_walk($a, 'myFunction');
print_r($a);

$b = [
    [
        'id' => 1,
        'name' => 'apple'
    ],
    [
        'id' => 2,
        'name' => 'apple'
    ],
    [
        'id' => 3,
        'name' => 'apple'
    ]
];

// 二维数组 也可更改
function myFunctions(&$value, $key, $keys)
{
    $value[$keys] = '6389';
}

array_walk($b, 'myFunctions','user_id');
print_r($b);